#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/9/14 12:52
# @Author  : leon yan
# @Site    :
# @File    : TechnologyDetail.py
# @Software: PyCharm

import Globalist as gl

from PyQt5.QtCore import pyqtSlot, QFile, QIODevice, QTextStream, Qt, QDir, QFileInfo, pyqtSignal, QStringListModel
from PyQt5.QtWidgets import (QApplication, QMainWindow, QMessageBox, QListWidgetItem, QFileDialog, QAbstractItemView)

from resource.TechnologyDetail_ui import Ui_QWFormTable


class QTechnologyDetail(QMainWindow, Ui_QWFormTable):
    bCloseDetailData = pyqtSignal()

    def __init__(self, parent=None, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.setupUi(self)
        # gl.init() # 调试用
        self.catalogType = {}
        # self._FlagEditable = (Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
        # self._FlagNotEditable = (Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
        self.model = QStringListModel(self)
        self.listDeviceView.setEditTriggers(QAbstractItemView.NoEditTriggers)
        aa = []
        for key, value in gl.global_var["deviceDict"].items():
            aa.append(value[0] + "_" + value[1])
        self.model.setStringList(aa)
        self.listDeviceView.setModel(self.model)
        self.logDir = r"./log/log.log"

    def __del__(self):  # 析构函数
        print("QTechnologyDetail is deleted")

    @pyqtSlot()
    def on_btnTechnology_clicked(self):
        self.bCloseDetailData.emit()


if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)
    objWindow = QTechnologyDetail()

    objWindow.show()
    sys.exit(app.exec_())
